package com.movie.demo.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.movie.demo.mapper.ArrangeMapper;
import com.movie.demo.pojo.Arrange;
import com.movie.demo.pojo.vo.Arrangeinfo;
import org.apache.xmlbeans.impl.xb.xsdschema.BlockSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ArrangeService extends ServiceImpl<ArrangeMapper, Arrange> implements com.movie.demo.service.ArrangeService {
    @Autowired
    private ArrangeMapper arrangeMapper;
    @Override
    public List<Arrangeinfo> selectArrange() {
        List <Arrangeinfo> arrangeinfos=arrangeMapper.selectArrangeList();
        return arrangeinfos;
    }

    @Override
    public boolean addArrange(Arrange arrange) {
        boolean flag=this.insert(arrange);
        return flag;
    }

    @Override
    public boolean updateState(int id) {
        Arrange result=this.selectById(id);
        if (result.getState()!=0) {
            result.setState(0);
        } else {
            result.setState(1);
        }
        return this.updateById(result);
    }

    @Override
    public boolean DeleteArrange(int id) {
        return this.deleteById(id);
    }

    @Override
    public boolean UpdateArrange(Arrange arrange) {
        return this.updateById(arrange);
    }

    @Override
    public List<Arrange> ArrangeTime(int mid, int cid, int rid) {
        List<Arrange> arrangeList=this.selectList(new EntityWrapper<Arrange>().eq("mid",mid).and()
                .eq("cid",cid).and().eq("rid",rid).and().eq("state",1));
        return arrangeList;
    }
}
